/**
 * Copyright (c) 2013 Axa Holding Belgium, SA. All rights reserved.
 * This software is the confidential and proprietary information of the AXA Group.
 */
package chabernac.gravidroid.model;

import java.util.Random;

import junit.framework.TestCase;
import chabernac.gravidroid.model.GravitySimulator;
import chabernac.gravidroid.model.Mass;
import chabernac.gravidroid.model.Vector;

public class SimulatorTest extends TestCase {
  private Random myRandom = new Random();
  
  public void testPerformance(){
    
    GravitySimulator theSimulator = new GravitySimulator();

    for(int i=0;i<50;i++){
      theSimulator.addMass( new Mass().setLocation( new Vector( Math.abs(myRandom.nextInt() % 400), Math.abs(myRandom.nextInt() % 400) )).setMass( 1 ).setRadius( 4 ).setSpeed( new Vector(myRandom.nextInt() % 200,myRandom.nextInt()  % 200) ) );
    }
    
    int times = 100;
    long t1 = System.currentTimeMillis();
    for(int i=0;i<times;i++){
      theSimulator.iterate();
    }
    long t2 = System.currentTimeMillis();
    
    float theMSPerIteration = (t2-t1) / times;
    
    System.out.println(theMSPerIteration + "ms / iteration");
  }
}
